package com.project.fiveCerealsSavoury.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.project.fiveCerealsSavoury.dao.DeliveryDao;
import com.project.fiveCerealsSavoury.domain.DeliveryDomain;
import com.project.fiveCerealsSavoury.exception.BizException;
import com.project.fiveCerealsSavoury.service.DeliveryService;

@Service
@Transactional
public class DeliveryServiceImpl implements DeliveryService{
	@Autowired
	private DeliveryDao deliveryDao;
	@Override
	public Integer add(DeliveryDomain deliveryDomain){
		return deliveryDao.add(deliveryDomain);
	}

	@Override
	public List<DeliveryDomain> list(String name)throws BizException {
		if(name == null)throw new BizException("送货人的姓名不能为空");
		return deliveryDao.list(name);
	}

	@Override
	public DeliveryDomain query(Integer orderId)throws BizException {
		if(orderId == null)throw new BizException("订单不存在");
		return deliveryDao.query(orderId);
	}

	@Override
	public List<DeliveryDomain> querys() {
		return deliveryDao.querys();
	}
	
}
